package com.cuitrip.business.tripservice.proxy;

import android.text.TextUtils;

import com.cuitrip.business.tripservice.model.ServiceInfo;
import com.lab.utils.ArrayUtil;

/**
 * 行程数据代理类
 * Created by ak on 15/9/23.
 */
public class ServiceFormProxy {


    private static ServiceFormProxy sInstance;

    public static ServiceFormProxy getInstance() {
        if (null == sInstance)
            sInstance = new ServiceFormProxy();
        return sInstance;
    }

    public enum InValidType {
        TITLE, ADDRESS, HIGHLIGHT, DESCRIPTION, OTHERS, DEMAND, PAY, MAIN_PIC, CORRECT;
    }

    public InValidType isFormComplete(ServiceInfo serviceInfo) {
        if (TextUtils.isEmpty(serviceInfo.getName())) {
            return InValidType.TITLE;
        }

        if (TextUtils.isEmpty(serviceInfo.getAddress())) {
            return InValidType.ADDRESS;
        }

        if (TextUtils.isEmpty(serviceInfo.getHighLight())) {
            return InValidType.HIGHLIGHT;
        }

        if (TextUtils.isEmpty(serviceInfo.getServiceDescript())) {
            return InValidType.DESCRIPTION;
        }

        /*if (TextUtils.isEmpty(serviceInfo.getServiceNotice())
                || TextUtils.isEmpty(serviceInfo.getServiceSafeTips())
                || TextUtils.isEmpty(serviceInfo.getServiceWearTips())
                || TextUtils.isEmpty(serviceInfo.getUnexpectedWeather())
                ) {
            return InValidType.OTHERS;
        }*/

        if (ArrayUtil.isNullOrEmpty(serviceInfo.getPic()) && TextUtils.isEmpty(serviceInfo.getBackPic())) {
            return InValidType.MAIN_PIC;
        }

        if (serviceInfo.getPreOrderDays() == 0
                || TextUtils.isEmpty(serviceInfo.getServiceTime())
                || serviceInfo.getMinBuyerNum() == 0 || serviceInfo.getMaxbuyerNum() == 0
                || TextUtils.isEmpty(serviceInfo.getMeetingPlace())
                ) {
            return InValidType.DEMAND;
        }

        if (TextUtils.isEmpty(serviceInfo.getPriceType()) || TextUtils.isEmpty(serviceInfo.getPrice())
                || TextUtils.isEmpty(serviceInfo.getFeeExclude())||
                TextUtils.isEmpty(serviceInfo.getFeeExclude())
                ){
            return InValidType.PAY;
        }

        return InValidType.CORRECT;
    }


}
